import java.util.*;

/**
 * Die Klasse <code>Project</code> implementiert ein Project.
 * 
 * @author anon
 * @version 23.01
 * 
 */

// ############################## Datenfelder ##############################

public class Project {
	private String name;
	private String description;
	private double rate;
	private Task myTask;
	
// ############################## Konstruktoren ##############################
	
	public Project(String name, String description, double rate) {
		this.name = name;
		this.description = description;
		this.rate = rate;
		myTask = null;
	}
	
// ############################## Methoden ##############################
	
	public String getName() {
		return name;
	}
	
	public double getDuration() {
		return myTask.getTimeRequired();
	}
	
	public double getTotalCost() {
		return (myTask.getCostEstimate());
	}
	
	public  Map<Calendar, List<Deliverable>> allDeliverables() {
		Set<Deliverable> tmpDev = myTask.allDeliverables();
		Map<Calendar, List<Deliverable>> res = new HashMap<Calendar, List<Deliverable>>();
		
		for (Deliverable d : tmpDev) {
			
			if(res.containsKey(d.getDate())) {
				List<Deliverable> tmpList = res.get(d.getDate());
				tmpList.add(d);
				res.put(d.getDate(), tmpList);
			}
			else {
				List<Deliverable> tmpList = new LinkedList<Deliverable>();
				tmpList.add(d);
				res.put(d.getDate(), tmpList);
			}
		}
		return res;
	}
	
	public void setTask(Task newTask) {
		myTask = newTask;
	}

}
